|
Q is a proprietary array processing language developed by Arthur Whitney and commercialized by Kx Systems. The language serves as the query language for kdb+, a disk based and in-memory, column-based database. kdb+ is based upon K, a terse variant of APL. Q is a thin wrapper around K, providing a more readable, English-like interface. ==Overview== The fundamental building blocks of Q are ''atoms'', ''lists'' and ''functions''. Atoms are scalars and include numeric, character and temporal data types. Lists are ordered collections of atoms (or other lists) upon which the higher level data structures ''dictionaries'' and ''tables'' are internally constructed. A dictionary is a map of a list of keys to a list of values. A table is a transposed dictionary of symbol keys and equal length lists (columns) as values. A ''keyed table'', analogous to a table with a primary key placed on it, is a dictionary where the keys and values are arranged as two tables. The following code demonstrates the relationships of the data structures (expressions to be evaluated appear prefixed with the "q)" prompt, with the output of the evaluation shown beneath): q)`john / an atom of type symbol `john q)50 / an atom of type integer 50 q)`john`jack / a list of symbols `john`jack q)50 60 / a list of integers 50 60 q)`john`jack!50 60 / a list of symbols and a list of integers combined to form a dictionary john| 50 jack| 60 q)`name`age!(`john`jack;50 60) / an arrangement known as a column dictionary name| john jack age | 50 60 q)flip `name`age!(`john`jack;50 60) / when transposed via the function "flip", the column dictionary becomes a table name age -------- john 50 jack 60 q)(flip (enlist `name)!enlist `john`jack)!flip (enlist `age)!enlist 50 60 / two equal length tables combined as a dictionary become a keyed table name| age ----| --- john| 50 jack| 60 These entities are manipulated via functions, which include the built-in functions that come with Q (which are actually defined as K macros) and user-defined functions. Functions are themselves a data type, and can be placed into lists, dictionaries and tables, or passed into other functions as parameters. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Q (programming language from Kx Systems)」の詳細全文を読む スポンサード リンク
|